<template>
  <u-form labelWidth="auto">
    <view>
      <view style="display: flex">
        <view>
          <view class="option" style="width: 520rpx">
            <view class="lf">款项名称</view>
            <view class="rl">{{ filterMultiDictText(dictOptions['paymentName'], item.paymentName + '') }}</view>
          </view>

          <view class="option" style="width: 520rpx">
            <view class="lf">应收金额（元）</view>
            <view class="rl">{{ item.amountReceivable }}</view>
          </view>
          <view class="option" style="width: 520rpx">
            <view class="lf">豁免类型</view>
            <view class="rl">{{ filterMultiDictText(dictOptions['exemptionType'], item.exemptionType + '') }}</view>
          </view>
          <view class="option" style="width: 520rpx">
            <view class="lf">豁免对象</view>
            <view class="rl" v-if="item.exemptionType === '1'">
              {{ filterMultiDictText(dictOptions['teamId'], item.exemptionManagementTeam + '') }}
            </view>
            <view class="rl" v-if="item.exemptionType === '2'">
              {{ filterMultiDictText(dictOptions['empId'], item.exemptionUndertaker + '') }}
            </view>
            <view class="rl" v-else>{{ projectHeadFormat(item.exemptionProjectHead) }}</view>
          </view>
          <view class="option" style="width: 520rpx">
            <view class="lf">豁免考核月份</view>
            <view class="rl">{{ item.exemptionDateBegin + '~' + item.exemptionDateEnd }}</view>
          </view>
          <view class="option" style="width: 520rpx">
            <view class="lf">罚款金额（元）</view>
            <view class="rl">{{ item.exemptionPenaltyAmount !==null || item.exemptionPenaltyAmount !=='' || item.exemptionPenaltyAmount !==undefined?Number(item.exemptionPenaltyAmount).toFixed(2):'' }}</view>
          </view>
        </view>

        <view style="flex: 1; display: flex; align-items: center; justify-content: flex-end">
          <u-icon name="edit-pen-fill" color="#2979ff" size="20" @click="handleEidtForm(item, index)"></u-icon>
          <u-line direction="col" length="20" margin="0 10rpx"></u-line>
          <u-icon name="trash-fill" color="red" size="20" @click="handleRemoveForm(item)"></u-icon>
        </view>
      </view>
    </view>
  </u-form>
</template>

<script>
import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'
// import selectTaskProgressInput from '@/pages/synergy/components/selectTaskProgressInput.vue'

export default {
  name: 'PaybackDisclaimerFormInfo',
  components: {
    // selectTaskProgressInput,
  },
  props: {
    index: {
      type: Number,
      default: null,
    },
    item: {
      type: Object,
      default: () => ({}),
    },
    progressVoList: {
      type: Array,
      default: () => [],
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    dictOptions: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      filterMultiDictText,
      initDictOptions,
      // dictOptions: {},
      // smallList: [],
    }
  },
  created() {
    // this.initDictConfig()
  },
  watch: {
    item: {
      handler(val) {},
      immediate: true,
      deep: true,
    },
  },
  methods: {
    projectHeadFormat(data) {
      if (data) {
        let tempArray = data.split(',') //根据逗号截取字符串为数组
        let textNameArray = []
        let tempString = '' // 翻译拼接后的字符串
        if (tempArray && tempArray.length > 1) {
          //数组长度大于1
          tempArray.forEach((item) => {
            //将每个翻译后的人员名称进行拼接
            textNameArray.push(filterMultiDictText(this.dictOptions['empId'], item + ''))
          })
          tempString = textNameArray.join(',')
          return tempString
        } else if (tempArray.length === 1) {
          //数组长度等于1
          return filterMultiDictText(this.dictOptions['empId'], tempArray[0] + '')
        } else {
          //数组为空
          return ''
        }
      } else {
        //数组不存在
        return ''
      }
    },
    handleCopyForm(item) {
      this.$emit('copy', [item, this.index])
    },
    handleEidtForm(item) {
      this.$emit('edit', [item, this.index])
    },
    handleRemoveForm(item) {
      uni.showModal({
        content: '确定删除吗？',
        success: (res) => {
          if (res.confirm) {
            this.$emit('remove', item)
          }
        },
      })
    },
    initDictConfig() {},
  },
}
</script>

<style scoped lang="scss">
.inforamtion {
  margin-top: 10rpx;
  padding: 10rpx;
  border-radius: 15rpx;
  box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.1);
}
</style>
